package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo5FlatMap {
  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf().setMaster("local[4]").setAppName("map")
    val sc: SparkContext = new SparkContext(conf)


    val rdd1: RDD[String] = sc.parallelize(List("java,spark", "scala,hadoop,hive"))


    /**
      * flatMap 对数据进行处理   传入一行可以返回多行
      *
      */

    val rdd2: RDD[String] = rdd1.flatMap(line => line.split(","))

    rdd2.foreach(println)


  }
}
